import api from "@/util/api.js";
async function findall(pageNo = 1, pageSize = 10, params = {}) {

    let resp = await api({
        url: "/reserve",
        method: "get",
        params: {
            pageNo,
            pageSize,
            ...params
        }
    });
    for (let i = 0; i < resp.data.length; i++) {
        resp.data[i].roomId = resp.data[i].room.roomId;
        resp.data[i].roomName = resp.data[i].room.roomName;
        resp.data[i].userId = resp.data[i].user.userId;
        resp.data[i].userName = resp.data[i].user.userName;
        console.log(resp);
    }
    return resp;
}
async function deletebyid(id) {
    let resp = await api({
        url: "/reserve",
        method: "delete",
        data: id
    });
    return resp;
}
function adduser(user) {
    let resp = api({
        url: "/reserve",
        method: "post",
        data: user
    });
    return resp;
}
function updateuser(user) {
    let resp = api({
        url: "/reserve",
        method: "put",
        data: user
    });
    return resp;
}


export { findall, deletebyid ,adduser,updateuser}